var cur_areaid;
var cur_province;
var cur_city;
var cur_county;
var userList;
var allArea = false;
function findProvinces() {
	$
			.ajax({
				type : "post",
				url : "/api/svc/userIndex.php",
				data : {
					fun : "findProvinceList"
				},
				success : function(B) {
					if (B.status == "ok") {
						var D = B.province;
						var E = "";
						var A = "";
						if ($("#ul-province").hasClass("all")) {
							E += "<li onclick='clk_province(this)'><span data='value' class='hide'></span><a href='javascript:void(0);' data='show' >全部</a></li>"
						}
						if ($("#ul-province2").hasClass("all")) {
							A += "<li onclick='clk_province(this)'><span data='value' class='hide'></span><a href='javascript:void(0);' data='show' >全部</a></li>"
						}
						for (var C = 0; C < D.length; C++) {
							E += "<li onclick='clk_province(this)'><span data='value' class='hide'>"
									+ D[C].id
									+ "</span><a href='javascript:void(0);' data='show'>"
									+ D[C].province + "</a></li>";
							A += "<li onclick='clk_province(this)'><span data='value' class='hide'>"
									+ D[C].id
									+ "</span><a href='javascript:void(0);' data='show'>"
									+ D[C].province + "</a></li>"
						}
						$("#ul-province").html(E);
						$("#ul-province2").html(A)
					}
				}
			})
}
function findCities(A) {
	$
			.ajax({
				type : "post",
				url : "/api/svc/userIndex.php",
				data : {
					fun : "findCityListByProvince",
					province : A
				},
				success : function(C) {
					if (C.status == "ok") {
						var E = C.city;
						var F = "";
						var B = "";
						if ($("#ul-city").hasClass("all")) {
							F += "<li onclick='clk_city(this)'><span data='value' class='hide'></span><a data='show' href='javascript:void(0);' >全部</a></li>"
						}
						if ($("#ul-city2").hasClass("all")) {
							B += "<li onclick='clk_city(this)'><span data='value' class='hide'></span><a data='show' href='javascript:void(0);' >全部</a></li>"
						}
						for (var D = 0; D < E.length; D++) {
							F += "<li onclick='clk_city(this)'><span data='value' class='hide'>"
									+ E[D].id
									+ "</span><a data='show' href='javascript:void(0);' >"
									+ E[D].city + "</a></li>";
							B += "<li onclick='clk_city(this)'><span data='value' class='hide'>"
									+ E[D].id
									+ "</span><a data='show' href='javascript:void(0);' >"
									+ E[D].city + "</a></li>"
						}
						$("#ul-city").html(F);
						$("#ul-city2").html(B)
					}
				}
			})
}
function findCounties(A) {
	$
			.ajax({
				type : "post",
				url : "/api/svc/userIndex.php",
				data : {
					fun : "findCountyListByCity",
					city : A
				},
				success : function(C) {
					if (C.status == "ok") {
						var E = C.result;
						var F = "";
						var B = "";
						if ($("#ul-county").hasClass("all")) {
							F += "<li onclick='clk_county(this)'><span data='value' class='hide'></span><a data='show' href='javascript:void(0);' >全部</a></li>"
						}
						if ($("#ul-county2").hasClass("all")) {
							B += "<li onclick='clk_county(this)'><span data='value' class='hide'></span><a data='show' href='javascript:void(0);' >全部</a></li>"
						}
						for (var D = 0; D < E.length; D++) {
							F += "<li onclick='clk_county(this)'><span data='value' class='hide'>"
									+ E[D].id
									+ "</span><a data='show' href='javascript:void(0);' >"
									+ E[D].county + "</a></li>";
							B += "<li onclick='clk_county(this)'><span data='value' class='hide'>"
									+ E[D].id
									+ "</span><a data='show' href='javascript:void(0);' >"
									+ E[D].county + "</a></li>"
						}
						$("#ul-county").html(F);
						$("#ul-county2").html(B)
					}
				}
			})
}
function findUsers(C, B, A) {
	$.ajax({
		type : "post",
		url : "/api/svc/userIndex.php",
		data : {
			fun : "findUserListByAreaIdAndFather",
			areaid : C,
			father : B
		},
		success : function(D) {
			if (D.status == "ok") {
				userList = D.result;
				if (A) {
					A(D.result)
				}
			}
		}
	})
}
function findUserListByWords(C, B, D, A) {
	$.ajax({
		type : "post",
		url : "/api/svc/userIndex.php",
		data : {
			fun : "findUserListByWords",
			areaid : cur_areaid,
			father : B
		},
		success : function(E) {
			if (E.status == "ok") {
				userList = E.result;
				if (A) {
					A(E.result)
				}
			} else {
				alert(E.reason)
			}
		}
	})
}
function clk_province(C) {
	var B = $(C).find("span[data='value']").text();
	var A = $(C).find("a[data='show']").text();
	cur_province = A;
	if ($("#province:visible").length > 0) {
		$("#province span[data='value']").text(B);
		$("#province span[data='show']").text(A);
		$("#city span[data='value']").text("");
		$("#city span[data='show']").text("市");
		$("#county span[data='show']").text("区");
		$("#county span[data='value']").text("");
		$("#ul-city").html("");
		$("#ul-county").html("")
	}
	if ($("#province2:visible").length > 0) {
		$("#province2 span[data='value']").text(B);
		$("#province2 span[data='show']").text(A);
		$("#city2 span[data='value']").text("");
		$("#city2 span[data='show']").text("市");
		$("#county2 span[data='show']").text("区");
		$("#county2 span[data='value']").text("");
		$("#ul-city2").html("");
		$("#ul-county2").html("")
	}
	findCities(A)
}
function clk_city(B) {
	var C = $(B).find("span[data='value']").text();
	var A = $(B).find("a[data='show']").text();
	cur_city = A;
	if ($("#city:visible").length > 0) {
		$("#city span[data='value']").text(C);
		$("#city span[data='show']").text(A);
		$("#county span[data='show']").text("区");
		$("#county span[data='value']").text("");
		$("#ul-county").html("")
	}
	if ($("#city2:visible").length > 0) {
		$("#city2 span[data='value']").text(C);
		$("#city2 span[data='show']").text(A);
		$("#county2 span[data='show']").text("区");
		$("#county2 span[data='value']").text("");
		$("#ul-county2").html("")
	}
	findCounties(A)
}
function clk_county(B) {
	var C = $(B).find("span[data='value']").text();
	var A = $(B).find("a[data='show']").text();
	cur_areaid = C;
	cur_county = A;
	if ($("#city:visible").length > 0) {
		$("#county span[data='show']").text(A);
		$("#county span[data='value']").text(C)
	}
	if ($("#city2:visible").length > 0) {
		$("#county2 span[data='show']").text(A);
		$("#county2 span[data='value']").text(C)
	}
}
function deleteRouter(B, A) {
	$.ajax({
		type : "post",
		url : "/api/svc/devIndex.php",
		data : {
			fun : "delRouter",
			routerid : B
		},
		success : function(C) {
			A(C)
		}
	})
}
function deleteTester(C, B, A) {
	$.ajax({
		type : "post",
		url : "/api/svc/devIndex.php",
		data : {
			fun : "delTester",
			testerid : C,
			userid : B
		},
		success : function(D) {
			A(D)
		}
	})
}
function deleteCtrl(B, A) {
	$.ajax({
		type : "post",
		url : "/api/svc/devIndex.php",
		data : {
			fun : "delCtrl",
			ctrlid : B
		},
		success : function(C) {
			A(C)
		}
	})
};